﻿using Microsoft.EntityFrameworkCore.Migrations;

namespace Project.Api.Migrations
{
    public partial class 建立主外键关系 : Migration
    {
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.AddColumn<int>(
                name: "Dormitoriesid",
                table: "MindaDormitory",
                type: "int",
                nullable: true);

            migrationBuilder.AddColumn<int>(
                name: "Mindasid",
                table: "MindaDormitory",
                type: "int",
                nullable: true);

            migrationBuilder.CreateIndex(
                name: "IX_MindaDormitory_Dormitoriesid",
                table: "MindaDormitory",
                column: "Dormitoriesid");

            migrationBuilder.CreateIndex(
                name: "IX_MindaDormitory_Mindasid",
                table: "MindaDormitory",
                column: "Mindasid");

            migrationBuilder.AddForeignKey(
                name: "FK_MindaDormitory_Dormitory_Dormitoriesid",
                table: "MindaDormitory",
                column: "Dormitoriesid",
                principalTable: "Dormitory",
                principalColumn: "id",
                onDelete: ReferentialAction.Restrict);

            migrationBuilder.AddForeignKey(
                name: "FK_MindaDormitory_Minda_Mindasid",
                table: "MindaDormitory",
                column: "Mindasid",
                principalTable: "Minda",
                principalColumn: "id",
                onDelete: ReferentialAction.Restrict);
        }

        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_MindaDormitory_Dormitory_Dormitoriesid",
                table: "MindaDormitory");

            migrationBuilder.DropForeignKey(
                name: "FK_MindaDormitory_Minda_Mindasid",
                table: "MindaDormitory");

            migrationBuilder.DropIndex(
                name: "IX_MindaDormitory_Dormitoriesid",
                table: "MindaDormitory");

            migrationBuilder.DropIndex(
                name: "IX_MindaDormitory_Mindasid",
                table: "MindaDormitory");

            migrationBuilder.DropColumn(
                name: "Dormitoriesid",
                table: "MindaDormitory");

            migrationBuilder.DropColumn(
                name: "Mindasid",
                table: "MindaDormitory");
        }
    }
}
